package com.pandy.juc;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @description: 线程池
 * @author: panhong
 * @date: 2025/3/20
 */
public class Code04_ThreadPoolDemo {

    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 2,
                1, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1), new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                Thread t = new Thread(r);
                t.setName("推送业务");
                return t;
            }
        }, new ThreadPoolExecutor.AbortPolicy());

        threadPoolExecutor.execute(() -> {});
    }
}
